<template>
    <cardComponent id="pwd-container" :pageTitle="pageTitle">
        <template slot="cardBody">
            <el-form
                :inline="true"
                :model="formDataMessage"
                ref="Edit"
                label-width="100px"
                size="small"
            >
                <el-form-item label="证件类型：">
                    <el-select v-model="formDataMessage.keyType" placeholder disabled clearable>
                        <el-option
                            v-for="item in papersType"
                            :label="item.label"
                            :key="item.code"
                            :value="item.code"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="证件号码：">
                    <el-input v-model="formDataMessage.custid" disabled placeholder="请输入" />
                </el-form-item>
                <el-form-item label="卡号：">
                    <el-select v-model="formDataMessage.CARDNBR" placeholder clearable>
                        <el-option
                            v-for="item in cardList"
                            :key="item.CARDNBR"
                            :label="item.CARDNBR"
                            :value="item.CARDNBR"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <div style="text-align: center;">
                    <el-button
                        type="primary"
                        size="small"
                        @click="hanleSubmit"
                        :loading="searchLoading"
                        class="submitBtn"
                    >转 接</el-button>
                </div>
            </el-form>
        </template>
    </cardComponent>
</template>

<script>
import { mapGetters } from 'vuex';
import { PAPERS_TYPE } from 'utils/Contants'; // 页面一些常量
import cardComponent from '@/components/cardComponent/cardComponent.vue';
import { getDictFromBankNum, getDictSelectList } from '@/utils/Common';
export default {
    name: 'pwdApply',
    components: {
        cardComponent,
    },
    data() {
        return {
            // 搜索loading
            searchLoading: false,
            cardList: [],
            papersType: PAPERS_TYPE,
            formDataMessage: {
                keyType: '',
                custid: '',
                CARDNBR: '',
            },
            pageTitle: '',
        };
    },
    async mounted() {
        this.getCardInfo();
        this.papersType = await getDictSelectList('IDTYPE', this);
    },
    computed: {
        ...mapGetters([
            'cardInfo_3004',
            'cardList_3601',
            'customerInfo_3002',
            'currentSessionId',
        ]),
    },
    created() {
        this.pageTitle = this.$route.meta.title;
        this.cardList = this.cardList_3601;

        this.formDataMessage.keyType = this.cardInfo_3004.KEYTYPE;
        this.formDataMessage.custid = this.cardInfo_3004.CUSTID;
    },
    methods: {
        getCardInfo() {
            if (this.customerInfo_3002.PINSET + '' === '1') {

                this.$alert(
                    `客户查询密码已设置，无法进行设置！`,
                    '设置查询密码',
                    { customClass: 'warning', type: 'warning', showClose: false },
                ).then(() => {
                    closePage(this.$route, this, 1);
                });


            }
            console.log(this.$route.params.cardNo);
            //this.searchFormOne.CARDNO = this.$route.params.cardNo;
            if (this.$route.params.cardNo) {
                this.formDataMessage.CARDNBR = this.$route.params.cardNo;
            } else {
                this.cardList.forEach((item) => {
                    if (this.cardInfo_3004.CARDNO === item.CARDNBR) {
                        this.formDataMessage.CARDNBR = item.CARDNBR;
                    }
                });
            }
        },
        hanleSubmit() {

            let confirmMsg = "当前卡号为" + this.formDataMessage.CARDNBR + ",确认转接设置查询密码吗？";
            this.$confirm(confirmMsg, '提示', { customClass: 'warning', type: 'warning' }).then(() => {
                // let menuid = 'CONF901';
                // var data = {
                //     "uui":top.softphone.uui,
                //     "IDTYPE":this.formDataMessage.keyType,
                //     "IDNO":this.formDataMessage.custid,
                //     "CARD":this.formDataMessage.CARDNBR
                // };
                // if (this.$route.meta.title === '身份验证') {
                //     menuid = 'CONF907';
                // } else if (this.$route.meta.title === '交易密码验证') {
                //     menuid = 'CONF909';
                // } else if (this.$route.meta.title === '客户级查询密码申请') {
                //     menuid = 'CONF901';
                // } else if (this.$route.meta.title === '客户级查询密码重置') {
                //     menuid = 'CONF902';
                // } else if (this.$route.meta.title === '客户级查询密码修改') {
                //     menuid = 'CONF903';
                // } else if (this.$route.meta.title === '交易密码申请') {
                //     menuid = 'CONF904';
                // } else if (this.$route.meta.title === '交易密码重置') {
                //     menuid = 'CONF905';
                // } else if (this.$route.meta.title === '交易密码修改') {
                //     menuid = 'CONF906';
                // }
                // 转接跳转
                // top.softphone.tranferIVRBtnClick('CONF901');
                chackPwdClick('CONF901', 'checkPwd');
            }, () => { });
        },
    },
};
</script>

<style lang="scss">
#pwd-container {
    .el-form--inline .el-form-item {
        display: block;
        text-align: center;
    }
    .el-form-item--small .el-form-item__content,
    .el-form-item--small .el-form-item__label {
        height: 32px;
    }
    .myCardComponent {
        -webkit-box-shadow: none;
        box-shadow: none !important;
    }
}
</style>
